﻿package pages
{
	import com.gaiaframework.templates.AbstractPage;
	import com.gaiaframework.events.*;
	import com.gaiaframework.debug.*;
	import com.gaiaframework.api.*;
	import com.greensock.plugins.*;
	import com.greensock.TweenMax;
	import flash.display.*;
	import flash.events.*;
	import ui.videos.NavTimeLine;
	import ui.videos.SlideItem;
	import utils.TextFieldUtil;
	
	public class TimeLinePage extends AbstractPage
	{	
		
		private var _nav:MovieClip;
		public var _navTimeLine:NavTimeLine;
		public function TimeLinePage()
		{
			super();
		}
		override public function transitionIn():void 
		{
			super.transitionIn();
			TextFieldUtil.setStyle(IStyleSheet(Gaia.api.getPage(Pages.INDEX).assets.styles).style);
			TweenPlugin.activate([ShortRotationPlugin, TransformAroundCenterPlugin, TransformAroundPointPlugin]);
			_nav = Gaia.api.getPage(Pages.NAV).content;
			_navTimeLine = new NavTimeLine();
			_navTimeLine.alpha = 0;
			TweenMax.to(_navTimeLine, 1, { alpha:1, delay:.5 } );
			addChild(_navTimeLine);
			_nav.updateNav();
			transitionInComplete();
			_onResize();
			stage.addEventListener(Event.RESIZE, _onResize);
			
		}
		
		private function _onResize(e:Event=null):void 
		{
			if (_navTimeLine)_navTimeLine.resize();
		}
		public function ready(obj:*):void
		{
			_navTimeLine.update(obj);
		}
		
		public function updateTimeLine(event:String):void
		{
			if(_navTimeLine!=null)_navTimeLine.updateTimelinePosition(event);
		}
		
		override public function transitionOut():void 
		{
			super.transitionOut();
			if (_nav)_nav.updateNav();
			if (_navTimeLine)
			{
				TweenMax.to(_navTimeLine, .5, { alpha:0, onComplete:function():void {
					_navTimeLine.destroy();
					stage.removeEventListener(Event.RESIZE, _onResize);
					transitionOutComplete();
				} } );
				
			}
		}
	}
}